<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form name="form1" class="form1">
        <input type="text" name="username" id="" class="username">
        <input type="text" name="password" class="password">
        <input type="submit" value="提交">
        <div class="add">提交</div>
    </form>
    <script src="./jquery-1.11.2.min.js"></script>
    <script>

        $(function () {

            $(".add").click(function () {
                console.log(123);
                var username = document.form1.username;
                var userpwd = document.form1.userpwd;
                var userclass = document.form1.userclass;
                $.ajax({
                    url: 'https://yangsaifei.gitee.io/data/login.php',
                    type: "post",
                    data:`username=${$('.form1 .username').val()}&password=${$('.form1 .password').val()}`,
                    success: function (res) {
                        console.log(res);
                    },
                    headers:{ 'Content-Type': 'application/x-www-form-urlencoded'}
                })
            })
        })
    </script>
</body>

</html>